package com.example.im.config;

import com.example.im.infra.constant.ImConstants;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author PC
 */
@Configuration
@ConfigurationProperties(prefix = "cus.ws")
public class WebSocketProperties {

    /**
     * 接收人是否排除自身，默认排除
     */
    private Boolean receiverExcludesHimselfFlag = true;

    /**
     * 消息是否排除接收人信息,默认不排除
     */
    private Boolean excludeReceiverInfoFlag = false;

    /**
     * 线程池信息
     */
    private ExecutorProperties executorProperties = new ExecutorProperties();

    /**
     * 发送消息给指定人的分隔符，默认为@
     */
    private String receiverSeparator = ImConstants.Symbol.AT;

    /**
     * 发送消息的渠道，默认websocket的发送
     */
    private String communicationType = ImConstants.CommunicationType.DEFAULT;

    /**
     * 发送给用户的redis通道名前缀，默认发送给指定用户用户redis-websocket-user，发送给全部人redis-websocket-all
     */
    private String redisChannelPrefix = "redis-websocket";

    public Boolean getReceiverExcludesHimselfFlag() {
        return receiverExcludesHimselfFlag;
    }

    public void setReceiverExcludesHimselfFlag(Boolean receiverExcludesHimselfFlag) {
        this.receiverExcludesHimselfFlag = receiverExcludesHimselfFlag;
    }

    public Boolean getExcludeReceiverInfoFlag() {
        return excludeReceiverInfoFlag;
    }

    public void setExcludeReceiverInfoFlag(Boolean excludeReceiverInfoFlag) {
        this.excludeReceiverInfoFlag = excludeReceiverInfoFlag;
    }

    public String getReceiverSeparator() {
        return receiverSeparator;
    }

    public void setReceiverSeparator(String receiverSeparator) {
        this.receiverSeparator = receiverSeparator;
    }

    public ExecutorProperties getExecutorProperties() {
        return executorProperties;
    }

    public void setExecutorProperties(ExecutorProperties executorProperties) {
        this.executorProperties = executorProperties;
    }

    public String getCommunicationType() {
        return communicationType;
    }

    public void setCommunicationType(String communicationType) {
        this.communicationType = communicationType;
    }

    public String getRedisChannelPrefix() {
        return redisChannelPrefix;
    }

    public void setRedisChannelPrefix(String redisChannelPrefix) {
        this.redisChannelPrefix = redisChannelPrefix;
    }

    /**
     * 线程池信息
     */
    public static class ExecutorProperties {
        /**
         * 核心线程数
         */
        private int corePoolSize = 10;
        /**
         * 最大线程数
         */
        private int maxPoolSize = 20;
        /**
         * 队列容量
         */
        private int queueCapacity = 50;
        /**
         * 线程活跃时间(秒)
         */
        private int keepAliveSeconds = 60;

        public int getCorePoolSize() {
            return corePoolSize;
        }

        public void setCorePoolSize(int corePoolSize) {
            this.corePoolSize = corePoolSize;
        }

        public int getMaxPoolSize() {
            return maxPoolSize;
        }

        public void setMaxPoolSize(int maxPoolSize) {
            this.maxPoolSize = maxPoolSize;
        }

        public int getQueueCapacity() {
            return queueCapacity;
        }

        public void setQueueCapacity(int queueCapacity) {
            this.queueCapacity = queueCapacity;
        }

        public int getKeepAliveSeconds() {
            return keepAliveSeconds;
        }

        public void setKeepAliveSeconds(int keepAliveSeconds) {
            this.keepAliveSeconds = keepAliveSeconds;
        }
    }
}
